package vn.sunnet.backviet01.game.coloa.util;

import org.anddev.andengine.entity.scene.menu.item.IMenuItem;
import org.anddev.andengine.entity.sprite.Sprite;
import org.anddev.andengine.opengl.texture.region.TextureRegion;

public class MyRadioButton extends Sprite implements IMenuItem{
	private final TextureRegion mCheckedTextureRegion;
	private final TextureRegion init;
	
	private final int ID;
	private boolean isCheck = false;
	
	public MyRadioButton(final int ID, float pX, float pY, TextureRegion pTextureRegion,final TextureRegion pCheckedTextureRegion) {
		super(pX, pY, pTextureRegion);
		this.ID = ID;
		this.init = pTextureRegion;
		this.mCheckedTextureRegion = pCheckedTextureRegion;
	}
	
	public void setCheck(boolean isCheck) {
		this.isCheck = isCheck;
	}
	
	public boolean isCheck() {
		return this.isCheck;
	}
	
	@Override
	public int getID() {
		// TODO Auto-generated method stub
		return ID;
	}

	@Override
	public void onSelected() {
		if (isCheck)
			this.updateTextureRegion(mCheckedTextureRegion, true);
		else
			this.updateTextureRegion(init,true);
	}

	@Override
	public void onUnselected() {
		if (isCheck)
			this.updateTextureRegion(mCheckedTextureRegion, true);
		else
			this.updateTextureRegion(init, true);
	}

	@Override
	public boolean checkPress(float arg0, float arg1) {
		return false;
	}

}
